package com.sh.data.engine.domain.dataquality.service;

import com.sh.data.engine.domain.base.model.PageResult;
import com.sh.data.engine.domain.dataquality.model.domain.*;
import com.sh.data.engine.domain.dataquality.model.param.DataQualityAddParExpressionParam;
import com.sh.data.engine.domain.dataquality.model.param.DataQualityRuleParam;
import com.sh.data.engine.domain.dataquality.model.param.SaveDataQualityScheduleParam;
import com.sh.data.engine.domain.workspace.manager.model.domain.UserDomain;
import com.sh.data.engine.repository.dao.integration.offline.entity.OfflineSyncEntity;

import java.util.List;

/**
 * @author tinglan.ys
 * @description:
 * @date 2022/2/15 下午6:09
 */
public interface DataQualityManagerService {

    PageResult<DataQualityTableInfoDomain> getTables(
        Long projectId,
        List<Long> themeIdList,
        Integer pageNum,
        Integer pageSize,
        String tableName,
        String order);

    /**
     * @description : 添加or编辑分区表达式
     * @author : tinglan.ys
     * @date : 2022/2/18
     */
    Boolean addParExpression(
        DataQualityAddParExpressionParam dataQualityAddParExpressionParam,
        Long projectId,
        String userId);

    /**
     * @description : 获取表达式列表
     * @author : tinglan.ys
     * @date : 2022/2/18
     */
    List<DataQualityTablePartitionDomain> getParExpressions(
        Long tblId,
        String tableName,
        Integer hasPartition,
        String parExpression,
        Long projectId,
        String userId);

    Boolean deleteParExpression(Long id);

    PageResult<DataQualityRuleDomain> rules(
        Long tblId, Integer ruleDiy, Long parExpressionId, Integer pageNum, Integer pageSize);

    Boolean saveRule(DataQualityRuleParam dataQualityRule, Long projectId, UserDomain userInfo);

    Boolean deleteRule(Long id);

    DataQualityRuleDetailDomain getRule(Long id);

    /**
     * @description : 获取规则模版，tableName这个参数现在不要了
     * @author : tinglan.ys
     * @date : 2022/4/26
     */
    List<DataQualityRuleTemplateDomain> getRuleTemplates(Integer templateTableType);

    /**
     * @description : 获取模版规则详情
     * @author : tinglan.ys
     * @date : 2022/11/17
     */
    DataQualityRuleTemplateDomain getRuleTemplateByTemplateId(Long templateId);

    List<DataQualityTableFieldDomain> getTableFields(Long tblId, Long projectId);

    DataQualityScheduleDomain getDataQualitySchedule(Long tblId, Long projectId);

    Boolean saveDataQualitySchedule(SaveDataQualityScheduleParam request, Long projectId);

    Boolean tryRun(Long tblId, Long partitionId, List<Long> ruleIds, Long projectId);

    void executeDataQualityRule(Long ruleId);

    /**
     * @description : 数据质量根据调度周期，保存调度
     * @author : tinglan.ys
     * @date : 2022/3/7
     */
    String saveSyncTask(
        OfflineSyncEntity.OfflineSyncSchedule schedule, String jobDesc, Long projectId, String tblId);

    /**
     * @description : 保存规则模板
     * @author : tinglan.ys
     * @date : 2022/8/30
     */
    Boolean saveRuleTemplates();

    List<DataQualityRuleDetailDomain> getListByPage(
        Long projectId, Integer pageSize, Integer pageNum);

    List<DataQualityTableDomain> dataQualityRuleDomainList(Long projectId);

    /**
     * 获取表规则数量
     *
     * @param tblIds 表id列表
     * @return
     */
    List<DataQualityTblRuleCountDomain> getTblRuleCount(List<Long> tblIds);
}
